<template>
	<view class="page">
		正在验证,请稍后...
	</view>
</template>

<script>
	import { get_authority_result } from '@/api/new_api.js'
	export default {
		data() {
			return {
				
			}
		},
		onLoad(options) {
			const _redirect_url = uni.getStorageSync('verification_redirect_url')
			if(_redirect_url) {
				this._redirect_url = _redirect_url
				uni.removeStorageSync('verification_redirect_url')
			}
			// H5回调页面 https://yjgold.tthweixin.com/facial-verification/index.html
			// 获取H5回传参数
			this._BizToken = options.BizToken
			this.init()
		},
		methods: {
			async init() {
				const url = this._redirect_url || '/pages/index/index'
				try {
					const {status, data} = await get_authority_result({BizToken: this._BizToken})
					if(status == 200) {
						this.$util.Tips({
							title: '已完成实名认证'
						}, ()=>{
							uni.redirectTo({
								url,
								fail: () => {
									uni.switchTab({
										url
									})
								}
							})
						})
						return
					}
				} catch (error) {
					//
				}
				this.$util.Tips({
					title: '认证失败'
				}, ()=>{
					uni.redirectTo({
						url,
						fail: () => {
							uni.switchTab({
								url
							})
						}
					})
				})
			}
		}
	}
</script>

<style scoped>
.page {
	padding: 30rpx;
}
</style>
